package com.jboltai.event;

/**
 * 事件异常
 */
public class EventError {


    private EventErrorType errorType;

    private String msg;

    private Throwable exception;


    public EventError(EventErrorType errorType, String msg, Throwable exception) {
        this.errorType = errorType;
        this.msg = msg;
        this.exception = exception;
    }


    public EventErrorType getErrorType() {
        return errorType;
    }

    public void setErrorType(EventErrorType errorType) {
        this.errorType = errorType;
    }

    /**
     * 获取完整的错误信息
     * @return
     */
    public String getFullMsg() {
        StringBuilder full = new StringBuilder();
        if (full != null) {
            full.append("[message]:").append(this.msg).append("\n");
        }
        if (this.exception != null) {
            full.append("[exception]:").append(this.exception.getMessage());
        }
        return full.toString();
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Throwable getException() {
        return exception;
    }

    public void setException(Throwable exception) {
        this.exception = exception;
    }

    @Override
    public String toString() {
        return "EventError{" +
                "errorType=" + errorType.getMsg() +
                ", msg='" + msg + '\'' +
                ", exception=" + exception +
                '}';
    }
}
